package com.work.service.impl;

import com.work.bean.ClassW;
import com.work.dao.DBDao;
import com.work.dao.impl.DBImpl;
import com.work.service.MyClassService;
import com.work.utils.Constants;
import com.work.utils.SQLUtil;

import java.util.HashMap;
import java.util.List;

/**
 * Created by Administrator on 2017/10/7.
 */
public class MyClassServiceImpl implements MyClassService {

    DBDao dao;

    public MyClassServiceImpl() {
        dao = new DBImpl();
    }

    @Override
    public HashMap<Integer, List> pageByTeacherId(int countPage, int whichPage, int teacherId) {
        return dao.page(countPage, whichPage, SQLUtil.pageByTeacherId(teacherId), Constants.CLASSW);
    }

    @Override
    public boolean deleteById(String deleteId) {
        return dao.insertAndDelAndUpdate(SQLUtil.deleteByClassId(deleteId));
    }

    @Override
    public boolean insertClass(ClassW classW) {
        return dao.insertAndDelAndUpdate(SQLUtil.insertClass(classW));
    }

    @Override
    public void update(ClassW classW) {
        dao.insertAndDelAndUpdate(SQLUtil.updateClassName(classW));
    }

    @Override
    public List<ClassW> findById(int classId) {
        return dao.find(SQLUtil.findByClassIdSql(classId),Constants.CLASSW);
    }
}
